﻿using B.S.Data.MES.API.Applications.BaseData.Command.ProductCommand;
using B.S.Domain.CangKu;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.BaseData.CommandHandlers.ProductCommandHandler
{
    public class QueryGoodCommandHandler : IRequestHandler<QueryGoodCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<Finished_ProductTest> _goodinformationRepository;
        public QueryGoodCommandHandler(IBaseRepository<Finished_ProductTest> goodinformationRepository)
        {
            _goodinformationRepository = goodinformationRepository;
        }
        public async Task<APIRequst<int>> Handle(QueryGoodCommand request, CancellationToken cancellationToken)
        {
            var ment = _goodinformationRepository.GetAll().FirstOrDefault(x=>x.FinisheId==request.finisheId);
            ment.InspectionStatus = true;
            await _goodinformationRepository.Update(ment);

            return await Task.FromResult(new APIRequst<int>
            {
                Code=RequstCode.成功,
                Msg=RequstCode.成功.ToString()
            });

         
        }
    }
}
